﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Users/MasterPage.master" AutoEventWireup="true"
    CodeFile="TicketList.aspx.cs" Inherits="Users_TicketList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 402px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h3 align="center">
        Ticket List</h3>
    <div style="width: 100%">
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" DataKeyNames="TicketID" DataSourceID="SqlDataSource1"
            PageSize="5" Width="100%">
            <Columns>
                <asp:BoundField DataField="TicketID" HeaderText="Ticket ID" InsertVisible="False"
                    ReadOnly="True" SortExpression="TicketID">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
                </asp:BoundField>
                <asp:BoundField DataField="FROM" HeaderText="FROM" ReadOnly="True" SortExpression="FROM">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:BoundField DataField="TO" HeaderText="TO" ReadOnly="True" SortExpression="TO">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:BoundField DataField="Depart Time" DataFormatString="{0:t} {0:D}" HeaderText="Depart Time"
                    SortExpression="Depart Time">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:BoundField DataField="GMT" DataFormatString="GMT {0}" SortExpression="GMT">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
                </asp:BoundField>
                <asp:BoundField DataField="TicketStatus" HeaderText="Ticket Status" SortExpression="TicketStatus">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:BoundField DataField="BoughtDay" DataFormatString="{0:d}" HeaderText="Bought Day"
                    SortExpression="BoughtDay">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:HyperLinkField DataNavigateUrlFields="TicketID" 
                    DataNavigateUrlFormatString="~/Users/TicketDetail.aspx?id={0}" Text="Details" />
            </Columns>
            <EmptyDataTemplate>
                No Ticket Found<br />
            </EmptyDataTemplate>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sqlString %>"
            OnInit="SqlDataSource1_Init" SelectCommand="SELECT Airline_Ticket.TicketID, Airline_Flight.[Depart Time], Airline_Ticket.TicketStatus, Airline_Ticket.BoughtDay, CAST(Airline_Cities_1.[City Name] AS varchar(50)) + ', ' + CAST(Airline_Cities_1.State AS varchar(50)) + ', ' + CAST(Airline_Cities_1.Country AS varchar(50)) AS [FROM], Airline_Cities_1.GMT, CAST(Airline_Cities.[City Name] AS varchar(50)) + ', ' + CAST(Airline_Cities.State AS varchar(50)) + ', ' + CAST(Airline_Cities.Country AS varchar(50)) AS [TO] FROM Airline_Cities INNER JOIN Airline_Route ON Airline_Cities.CityID = Airline_Route.DestinationCityID INNER JOIN Airline_Schedule ON Airline_Route.RouteID = Airline_Schedule.RouteID INNER JOIN Airline_Flight ON Airline_Schedule.SchedueID = Airline_Flight.ScheduleID INNER JOIN Airline_Ticket ON Airline_Flight.FlightID = Airline_Ticket.FlightID INNER JOIN Airline_Cities AS Airline_Cities_1 ON Airline_Route.OriginalCityID = Airline_Cities_1.CityID WHERE (Airline_Ticket.UserID = @UserID)">
            <SelectParameters>
                <asp:Parameter Name="UserID" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
    </div>
    <div>
        <table class="style1">
            <tr style="color: #FF3300; background-color: #CCFFFF; font-weight: bold">
                <td colspan="2">
                    Confirm Booked Ticket
                </td>
            </tr>
            <tr>
                <td align="right" class="style2">
                    Enter Ticket ID you want to confirm <asp:TextBox ID="tbConfirm" runat="server"></asp:TextBox>
                    <asp:CustomValidator ID="CustomValidator1" runat="server" 
                        ErrorMessage="CustomValidator" 
                        onservervalidate="CustomValidator1_ServerValidate" ValidationGroup="confirm"><br />invalid input</asp:CustomValidator>
                &nbsp;</td>
                <td align="left">
                    <asp:LinkButton ID="lbConfirm" runat="server" onclick="lbConfirm_Click" 
                        ValidationGroup="confirm" 
                        onclientclick="return confirm('Are You sure you want to Confirm this Ticket ?')">Confirm Ticket</asp:LinkButton>
                </td>
            </tr>
            <tr style="color: #FF3300; background-color: #CCFFFF; font-weight: bold">
                <td colspan="2">
                    Cancel Ticket
                </td>
            </tr>
            <tr>
                <td align="right" class="style2">
                    Enter Ticket ID you want to cancel <asp:TextBox ID="tbCancel" runat="server"></asp:TextBox>
                    <asp:CustomValidator ID="CustomValidator2" runat="server" 
                        ErrorMessage="CustomValidator" 
                        onservervalidate="CustomValidator2_ServerValidate" ValidationGroup="cancel"><br />invalid input</asp:CustomValidator>
                &nbsp;</td>
                <td align="left">
                    <asp:LinkButton ID="lbCancel" runat="server" onclick="lbCancel_Click" 
                        ValidationGroup="cancel" 
                        onclientclick="return confirm('Are You sure you want to Cancel this Ticket ?')">Cancel Ticket</asp:LinkButton>
                </td>
            </tr>
            <tr style="color: #FF3300; background-color: #CCFFFF; font-weight: bold">
                <td colspan="2">
                    Reschedule Flight
                </td>
            </tr>
            <tr>
                <td class="style2" align="right">
                    Enter ticket you want to Reschedule
                    &nbsp;
                    <asp:TextBox ID="tbReschedule" runat="server"></asp:TextBox>
                    <asp:CustomValidator ID="CustomValidator3" runat="server" 
                        ErrorMessage="CustomValidator" 
                        onservervalidate="CustomValidator3_ServerValidate" 
                        ValidationGroup="reschedule"><br />invalid input</asp:CustomValidator>
                </td>
                <td align="left">
                    <asp:LinkButton ID="lbReschedule" runat="server" onclick="lbReschedule_Click" 
                        ValidationGroup="reschedule">Reschedule flight</asp:LinkButton>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
